/* main.c
 *
 * Copyright (C) 2007 Andre Moreira Magalhaes <andrunko@gmail.com>
 * Copyright (C) 2007 Renato Araujo Oliveira Filho <renatox@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <gtk/gtk.h>

#include "gtktransition.h"

static gboolean on_delete_event (GtkWidget      *window,
                                 GdkEvent       *event,
                                 gpointer        unused_data);

int
main (int argc, gchar *argv[])
{
  GtkWidget *window;
  GtkWidget *label;
  GtkTransition *transition;
  GtkTransitionState *state1, *state2;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window),
                        "An useless animation");

  g_signal_connect (window, "delete-event",
                    G_CALLBACK (on_delete_event), NULL);

  label = gtk_label_new ("An useless animation");
  gtk_container_add (GTK_CONTAINER (window), label);

  transition = gtk_transition_new (2000);
  gtk_timeline_set_loop (GTK_TIMELINE (transition), TRUE);

  state1 = gtk_transition_state_new (G_OBJECT (label));
  gtk_transition_state_set (state1,
                            "angle", 0.0, 360.0,
                            NULL);
  gtk_transition_add_state (transition,
                            state1,
                            NULL,
                            0.5);
  g_object_unref (state1);

  state2 = gtk_transition_state_new (G_OBJECT (label));
  gtk_transition_state_set (state2,
                            "angle", 360.0, 0.0,
                            NULL);
  gtk_transition_add_state (transition,
                            state2,
                            state1,
                            1.0);
  g_object_unref (state2);

  gtk_timeline_start (GTK_TIMELINE (transition));

  gtk_widget_show_all (window);
  gtk_main ();

  return 0;
}

static gboolean
on_delete_event (GtkWidget *window,
                 GdkEvent  *event,
                 gpointer   unused_data)
{
  gtk_main_quit ();
}
